{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import math\n",
    "import random\n",
    "import warnings\n",
    "from sklearn.preprocessing import LabelEncoder,MinMaxScaler,OneHotEncoder\n",
    "warnings.filterwarnings(\"ignore\")#忽略警告"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.导入数据dbscan_test.csv，在epsilon的值为2.01，minPoints的值为4的情况下确定核心点、边界点以及噪音点。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "数据导入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(17, 2)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x249b33dd640>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAATfElEQVR4nO3df+xldX3n8eerw9iOaDpQvjuFAR3bJbOh7QLmhmp0DVrLrxphjdmFNC3uspklsVndGLqwTequ/aNu2NqtpdVQYcGNpW51GEmLjlNqQt0o+h1+yAhMQReX+TIyX4oDpE4i0Pf+cc/Y65d7Z75z7/3++szzkdzcez7nc+75nBx4zf1+zvl8TqoKSVK7fmylGyBJWloGvSQ1zqCXpMYZ9JLUOINekhp3wko3YJhTTjmltmzZstLNkKQ1Y/fu3U9X1cywdasy6Lds2cLs7OxKN0OS1owk3xm1zq4bSWqcQS9JjTPoJalxBr0kNc6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N+4CHB5b/G/D7VfVPge8BV61Iq5bWHwBfqKp/BpxN//ibPddJNgP/AehV1c8D64DLafNc3wJctKBs1Lm9GDize20DPjbuTtds0APnAY9V1ber6gfAnwGXrnCblkRV7a+qe7vPz9P/H38z/eO9tat2K3DZijRwiSQ5HfgV4BPdcoC3AZ/pqrR4zD8JvAW4CaCqflBVB2n8XNN/CNKGJCcArwT20+C5rqq7gWcWFI86t5cCn6y+rwIbk5w6zn7XctBvBp4YWN7XlTUtyRbgXOAeYFNV7e9WfRfYtFLtWiL/A/hN4B+65Z8CDlbVi91yi+f8dcA88D+7LqtPJDmRhs91Vc0B/x34f/QD/llgN+2f68NGndupZdxaDvrjTpJXAZ8F3l9Vzw2uq/59ss3cK5vkHcCBqtq90m1ZZicArwc+VlXnAn/Pgm6aBs/1SfR/vb4OOA04kZd3bxwXlurcruWgnwPOGFg+vStrUpL19EP+U1W1vSt+6vCfct37gZVq3xJ4E/DOJI/T75Z7G/2+643dn/fQ5jnfB+yrqnu65c/QD/6Wz/Xbgf9bVfNV9QKwnf75b/1cHzbq3E4t49Zy0H8dOLO7Mv8K+hdv7ljhNi2Jrm/6JuDhqvrIwKo7gCu7z1cCn1vuti2Vqrquqk6vqi30z+1fV9WvAl8C3t1Va+qYAarqu8ATSbZ2Rb8EPETD55p+l80bkryy+2/98DE3fa4HjDq3dwC/3t198wbg2YEunmNTVWv2BVwC/C3wLeC3Vro9S3icb6b/59w3gPu71yX0+6zvAh4F/go4eaXbukTHfz7wF93nnwG+BjwG/Dnw4yvdviU43nOA2e587wBOav1cA/8VeATYA/wv4MdbPNfAbfSvQ7xA/6+3q0adWyD07yz8FvAg/buSxtqvUyBIUuPWcteNJGkRDHpJapxBL0mNM+glqXEGvSQ1zqCXpMYZ9JLUuP8PLs4JJ4qSc3EAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "date=np.array(pd.read_csv('dbscan_test.csv',header=None))\n",
    "print(date.shape)\n",
    "plt.scatter(date[:,0],date[:,1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义欧式距离函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def Distance(a,b):\n",
    "    return np.sqrt(np.sum(np.power(a - b, 2)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "DBSCAN算法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def dbscan(date, eps, minpts):\n",
    "    num=date.shape[0]\n",
    "    unvisited=[i for i in range(num)]# 还未访问的点\n",
    "    visit=[]# 已经访问的点\n",
    "    cluster=[-1 for i in range(num)]# 保存聚类结果\n",
    "    k=-1\n",
    "    while len(unvisited)>0:\n",
    "        p = random.choice(unvisited)# 在未访问的点中随机选择一个作为核心点\n",
    "        unvisited.remove(p)\n",
    "        visit.append(p)\n",
    "        N = []# 邻域内的点\n",
    "        for i in range(num):# 遍历数据集，判断其他点是否在该点的邻域之内\n",
    "            if (Distance(date[p,:],date[i,:])<=eps):\n",
    "                N.append(i)\n",
    "        if len(N)<minpts:#如果边界点数小于阈值，则该点为噪声点，标记为-1\n",
    "            cluster[p]=-1\n",
    "        else:# 如果大于等于阈值，意味着该点为核心点\n",
    "            k=k+1# 为该点创建一个新的标签\n",
    "            cluster[p]=k\n",
    "            for i in N:# 遍历邻域内每一个点\n",
    "                # \"感染\"，将每一个邻域内的点作为核心点寻找边界点\n",
    "                if i in unvisited:\n",
    "                    unvisited.remove(i)\n",
    "                    visit.append(i)\n",
    "                    M=[]\n",
    "                    for j in range(num):# 遍历数据集，判断其他点是否在该点的邻域之内\n",
    "                        if (Distance(date[i,:],date[j,:])<=eps):\n",
    "                            M.append(j)\n",
    "                    if len(M)>=minpts:\n",
    "                        for t in M:# 若新点不在N中，将它加入N中\n",
    "                            if t not in N:\n",
    "                                N.append(t)\n",
    "                if cluster[i]==-1:\n",
    "                    cluster[i]=k\n",
    "    return cluster\n",
    "                    \n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "输出聚类结果信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def re(cluster):\n",
    "    s=set(cluster)\n",
    "    number_c=len(s)-1\n",
    "    zao_number=cluster.count(-1)\n",
    "    D={}\n",
    "    for i in s:\n",
    "        if i>-1:\n",
    "            D[i]=cluster.count(i)\n",
    "    print(f'集群数量：{number_c},噪声点数量：{zao_number}，各族群数量：{D}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, -1, 2, 2, 2, -1, 2]\n",
      "集群数量：3,噪声点数量：2，各族群数量：{0: 5, 1: 6, 2: 4}\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x249b3ba2c70>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaQAAAETCAYAAAB5g3L4AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAxOAAAMTgF/d4wjAAAci0lEQVR4nO3dfZBcdZ3v8fenH2YmyQQSIAkhTRIgGEXFyJJFuQQsgUUQWS+yskFdr4Z1o5crW9FbpaziFoqo94oWu6WAgM8ursAFylVYVB52QTCaEGERkhCSMCGRPJJMknns7/2je7CT9Ew6Mz3dp3s+r6pT6T7n1+d8+9Tp+eSc/vXvKCIwMzOrt1S9CzAzMwMHkpmZJYQDyczMEs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f6ACy9a65RvtlNvAY8Gvg3d4ffA34p5Lj5Ojiv2Pu8wMI2AacXHKsdAETx8oxApwJ5IC1wLyS+YMeD6NxrNR9R1R5p04FdgKZkgNtEzCn3rXVcZ+cCqwtPu4c+MNTfP4b4Jx611iDfZACfgH8GfBQSSCN1f0xofg5OWy/+WPy81N8n1uBM4vPTwY2AC1j7RgpDaShjofROlaa7ZLdscDGiOgDiMKeWg/MrGtV9XUlcI+kIyn8z25TybK1jI19swR4NCJ+NzBjjO+PEyicEVwl6beS/kPS2YzRz0/xfV4K3CVpHfCfwAcpnCGN1WMEhj4eRuVYabZAshKSrqLwv5lP17uWepH0BuA9wBfqXUuCZIBZwDMRcSrwceDHjLE7SA+QlAE+A1wcEbOAs4HvM0b3Rz01WyC9CEwvHmBIEoXEXl/XqupA0ieBi4HzI2JPRGwF+iQdXdJsNs2/bxZQeJ+rJK0F3gLcDLyXsbk/oPAe88APASJiOfAChZAai5+fecAxEfEIQEQspfBd0cmM3WMEhv57Oip/a5sqkCLiZWAZ8P7irPcAHRGxun5V1Z6kJcBC4NyI2FGy6CfA4mKb+cAM4OGaF1hDEfHNiJgeEbMjYjbwOPCRiPgmY3B/AETEFuCXwHkAko4DjgMeZWx+fgb+uL4OoNgr9QTgOcboMQJD/z0drb+1TTdSg6S5wHeAIyl86fahiHiqrkXVkKQchQ/YGmBXcXZ3RJwmaRqFSxHHAT3AFRHxYH0qrQ9JDwFfj4i7x/L+kHQ8cCtwFIWzpWsi4s6x+vmRtBC4isK+SAHXRcSPxsoxIukm4J3A0RQ6eOyKiDlDHQ+jcaw0XSCZmVljaqpLdmZm1rgcSGZmlggOJDMzSwQHkpmZJYIDyczMEsGBZGZmieBAMjOzRHAgmZlZIjiQzMwsEf4/YhjQXfbSzvEAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 480x320 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "eps=2.01\n",
    "minpts=4\n",
    "cluster=dbscan(date,eps,minpts)\n",
    "print(cluster)\n",
    "re(cluster)\n",
    "\n",
    "x = date[:,0]\n",
    "y = date[:,1]\n",
    "plt.figure( dpi=80)\n",
    "plt.scatter(x,y, c=cluster, marker='o')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.对数据进行预处理，试用Python实现DBSCAN算法，测试不同的参数对聚类结果的影响，并对数据X_data.csv测试一下聚类结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5000, 400)\n"
     ]
    }
   ],
   "source": [
    "x_data=np.array(pd.read_csv('X_data.csv',header=None))\n",
    "print(x_data.shape)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义阈值为4，eps从2-3，每隔0.2测试一次，查看结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "eps=2.0,MinPts=4 --- 集群数量：8,噪声点数量：4515，各族群数量：{0: 449, 1: 4, 2: 7, 3: 7, 4: 4, 5: 5, 6: 4, 7: 5}\n",
      "eps=2.2,MinPts=4 --- 集群数量：16,噪声点数量：4396，各族群数量：{0: 471, 1: 51, 2: 7, 3: 12, 4: 4, 5: 12, 6: 4, 7: 5, 8: 5, 9: 4, 10: 7, 11: 5, 12: 4, 13: 5, 14: 4, 15: 4}\n",
      "eps=2.4,MinPts=4 --- 集群数量：30,噪声点数量：4146，各族群数量：{0: 137, 1: 479, 2: 5, 3: 7, 4: 11, 5: 6, 6: 6, 7: 79, 8: 20, 9: 4, 10: 5, 11: 7, 12: 4, 13: 4, 14: 4, 15: 9, 16: 4, 17: 5, 18: 4, 19: 5, 20: 8, 21: 4, 22: 6, 23: 5, 24: 5, 25: 4, 26: 5, 27: 4, 28: 4, 29: 4}\n",
      "eps=2.6,MinPts=4 --- 集群数量：42,噪声点数量：3792，各族群数量：{0: 893, 1: 4, 2: 25, 3: 6, 4: 10, 5: 23, 6: 6, 7: 3, 8: 18, 9: 6, 10: 6, 11: 10, 12: 37, 13: 22, 14: 5, 15: 8, 16: 5, 17: 4, 18: 4, 19: 4, 20: 5, 21: 4, 22: 4, 23: 3, 24: 6, 25: 4, 26: 7, 27: 8, 28: 3, 29: 4, 30: 3, 31: 8, 32: 5, 33: 6, 34: 2, 35: 8, 36: 5, 37: 4, 38: 6, 39: 7, 40: 4, 41: 3}\n",
      "eps=2.8,MinPts=4 --- 集群数量：30,噪声点数量：3397，各族群数量：{0: 1164, 1: 9, 2: 179, 3: 65, 4: 22, 5: 6, 6: 4, 7: 24, 8: 8, 9: 8, 10: 6, 11: 6, 12: 4, 13: 18, 14: 4, 15: 14, 16: 5, 17: 6, 18: 7, 19: 4, 20: 5, 21: 4, 22: 4, 23: 4, 24: 4, 25: 3, 26: 4, 27: 4, 28: 4, 29: 4}\n",
      "eps=3.0,MinPts=4 --- 集群数量：41,噪声点数量：2909，各族群数量：{0: 1376, 1: 95, 2: 275, 3: 7, 4: 28, 5: 4, 6: 83, 7: 6, 8: 39, 9: 18, 10: 5, 11: 3, 12: 11, 13: 4, 14: 12, 15: 6, 16: 11, 17: 5, 18: 5, 19: 5, 20: 6, 21: 6, 22: 5, 23: 8, 24: 4, 25: 4, 26: 2, 27: 9, 28: 4, 29: 6, 30: 4, 31: 3, 32: 3, 33: 5, 34: 4, 35: 4, 36: 4, 37: 2, 38: 3, 39: 3, 40: 4}\n"
     ]
    }
   ],
   "source": [
    "for eps in [2+i*0.2 for i in range(6)]:\n",
    "    print(f'eps={eps},MinPts=4 ---',end=' ')\n",
    "    cluster=dbscan(x_data,eps,4)\n",
    "    re(cluster)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "集群数量：12,噪声点数量：617，各族群数量：{0: 4336, 1: 3, 2: 6, 3: 2, 4: 4, 5: 7, 6: 7, 7: 3, 8: 4, 9: 5, 10: 3, 11: 3}\n"
     ]
    }
   ],
   "source": [
    "cluster=dbscan(x_data,4,4)\n",
    "re(cluster)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "集群数量：1,噪声点数量：174，各族群数量：{0: 4826}\n"
     ]
    }
   ],
   "source": [
    "cluster=dbscan(x_data,4.5,4)\n",
    "re(cluster)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "0ea2ea13f89004d253f237dbfddddbdca6ade9e7c69d0cba8f71d034288dfba7"
  },
  "kernelspec": {
   "display_name": "Python 3.8.8 64-bit ('tensorflow': conda)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
